package com.itheima.homework1.num1;

import java.util.ArrayList;

public class Test {
    public static void main(String[] args) {
        //创建一个集合 存储学生信息
        ArrayList<Student> list = new ArrayList<>();
        Student s1 = new Student(1, "小亮", 99);
        Student s2 = new Student(2, "小强", 85);
        Student s3 = new Student(3, "小响", 90);
        Student s4 = new Student(4, "小勇", 75);
        list.add(s1);
        list.add(s2);
        list.add(s3);
        list.add(s4);

        int minScore = s1.getScore();
        int index = 0;
        for (int i = 0; i < list.size(); i++) {
            Student s = list.get(i);
            if (s.getScore() < minScore){
                minScore = s.getScore();
            }
            //得到最小分数的索引值
            if (s.getScore() == minScore){
                index = i;
            }
        }
        System.out.println("最低分：" + minScore);
        //得到了索引值 删除该索引值对应的学生信息
        list.remove(index);

        //遍历集合 打印学生信息
        for (int i = 0; i < list.size(); i++) {
            Student s = list.get(i);
            System.out.println(s.getId() + " " + s.getName() + " " + s.getScore());
        }


    }
}
